package com.example.ecommercealibabanacosclient.controller;


import com.example.ecommercealibabanacosclient.service.NacosClientService;
import com.example.ecommercecommon.vo.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/nacos-client")
public class nacosClientController {

    private final NacosClientService nacosClientService;

    public nacosClientController(NacosClientService nacosClientService) {
        this.nacosClientService = nacosClientService;
    }

    @GetMapping("/service-instance")
    public CommonResponse<List> logNacosClientInfo(@RequestParam(defaultValue = "e-commerce-nacos-client") String serviceId) {

        log.info("coming in log:[{}]",serviceId);
        return  nacosClientService.getNacosClientsInfo(serviceId);
    }
}